import tapWaterLayer from './layer'
import tapWaterMap from './map'
import tapWaterMarker from './marker'
import tapWaterFormat from './format'
import tapWaterPolygon from './polygon'
// import ysPolyline from './polyline'
// import ysControl from './control'
import tapWaterInteraction from './interaction'

function Map(containerId, centerCoor, zoom, proj, minZoom, maxZoom) {
    this.map = tapWaterMap.init(containerId, centerCoor, zoom, proj, minZoom, maxZoom);
    this.view = this.map.getView();
    this.layer = new tapWaterLayer(this.map);
    this.marker = new tapWaterMarker(this.map);
    this.format = new tapWaterFormat(this.map);
    this.polygon = new tapWaterPolygon(this.map);
    // this.polyline = new ysPolyline(this.map);
    // this.control = new ysControl(this.map);
    this.interaction = new tapWaterInteraction(this.map);
}

/**
 * @description: 设置显示中心
 * @param {array} lonlat 中心点经纬度
 * @param {int} zoom 缩放级别 
 * @return {*}
 */
Map.prototype.panTo = function (lonlat, zoom) {
    if (zoom) {
        this.view.animate({
            zoom: zoom,
            center: lonlat,
            duration: 700
        });
    }
    else {
        this.view.animate({
            center: lonlat,
            duration: 1000 //动画效果时间
        })
    }
};

Map.prototype.moveToExtent = function (extent) {
    this.map.getView().fit(extent, { duration: 800 });
}

export default Map
